package com.taptech.doufu.ui.activity;

import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;

import com.taptech.doufu.R;
import com.taptech.doufu.constant.Constant;
import com.taptech.doufu.listener.HttpResponseListener;
import com.taptech.doufu.services.personalcenter.PersonalInfoService;
import com.taptech.doufu.ui.activity.base.DiaobaoBaseActivity;
import com.taptech.doufu.util.UIUtil;
import com.taptech.doufu.net.httputils.HttpResponseObject;

/**
 * 
 <p>
 * Company: DiaoBao
 * </p>
 * 
 * 
 @author huangzh
 * 
 * 
 @date 2014-3-20
 */
public class PersonalValidateInviteActivity extends DiaobaoBaseActivity implements
		HttpResponseListener {

	private EditText inviteCode;


	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.personal_center_activity_validate_inivite_code);		
		initView();
	}

	private void initView() {
		inviteCode = (EditText)findViewById(R.id.personal_center_activity_invite_code);
	}

	@Override
	public void handleResponse(int handleType, HttpResponseObject response) {
		try {
		
			if(response.getStatus()==Constant.STATUS_SUCCESS)
			{
				UIUtil.toastMessage(this, "兑换豆子成功");
			}
			else
			{
				UIUtil.toastMessage(this, response.getUser_msg());
			}
			
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	public void back(View view)
	{
		onBackPressed();
	}

	public void submit(View view)
	{
		if(TextUtils.isEmpty(inviteCode.getText()))
		{
			UIUtil.toastMessage(this, "验证码不能为空");
			return;
		}	
		PersonalInfoService.getInstance().validateInviteCode(inviteCode.getText().toString(),this);
		
	}
}
